import request from '@/config/axios'

// 员工假期余额管理 VO
export interface EmployeeLeaveBalanceVO {
  id: number // 序号
  years: number // 年份
  leaveType: string // 假期类型
  standardDays: number // 标准天数
  remaining: number // 剩余天数
  userName: string // 员工姓名
  userId: number // 员工编号
  standardId: number
}

// 员工假期余额管理 API
export const EmployeeLeaveBalanceApi = {
  // 查询员工假期余额管理分页
  getEmployeeLeaveBalancePage: async (params: any) => {
    return await request.get({ url: `/oa/employee-leave-balance/page`, params })
  },

  // 查询假期类型标准分页
  getHolidayStandardsPage: async (params: any) => {
    return await request.get({ url: `/oa/holiday-standards/page`, params })
  },

  // 查询假期类型标准详情
  getHolidayStandards: async (id: number) => {
    return await request.get({ url: `/oa/holiday-standards/get?id=` + id })
  },

  // 查询员工假期余额管理详情
  getEmployeeLeaveBalance: async (id: number) => {
    return await request.get({ url: `/oa/employee-leave-balance/get?id=` + id })
  },

  // 新增员工假期余额管理
  createEmployeeLeaveBalance: async (data: EmployeeLeaveBalanceVO) => {
    return await request.post({ url: `/oa/employee-leave-balance/create`, data })
  },

  // 修改员工假期余额管理
  updateEmployeeLeaveBalance: async (data: EmployeeLeaveBalanceVO) => {
    return await request.put({ url: `/oa/employee-leave-balance/update`, data })
  },

  // 删除员工假期余额管理
  deleteEmployeeLeaveBalance: async (id: number) => {
    return await request.delete({ url: `/oa/employee-leave-balance/delete?id=` + id })
  },

  // 导出员工假期余额管理 Excel
  exportEmployeeLeaveBalance: async (params) => {
    return await request.download({ url: `/oa/employee-leave-balance/export-excel`, params })
  },
}

// 生成员工合同期内假期余额
export const generateEmployeeLeaveBalance = (data: { userId: number, userName: string, hireDate: number, endDate: number }) => {
  return request.post({ url: '/oa/employee-leave-balance/generate', data })
}
